﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Best.SmartCms.API.Migrations
{
    public partial class News : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<long>(
                name: "ParentId",
                table: "Department",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 50,
                oldNullable: true);

            migrationBuilder.CreateTable(
                name: "News",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                   
                    ChannelId = table.Column<long>(nullable: false),
                    Title = table.Column<string>(maxLength: 100, nullable: true),
                    Summer = table.Column<string>(maxLength: 500, nullable: true),
                    Keywords = table.Column<string>(maxLength: 200, nullable: true),
                    Author = table.Column<string>(maxLength: 50, nullable: true),
                    Content = table.Column<string>(maxLength: 10000, nullable: true),
                    ReadNum = table.Column<int>(nullable: true),
                    CreatedTime = table.Column<DateTime>(nullable: true),
                    CreatorId = table.Column<string>(maxLength: 50, nullable: true),
                    CreatorName = table.Column<string>(maxLength: 50, nullable: true),
                    UpdatedTime = table.Column<DateTime>(nullable: true),
                    UpdatorId = table.Column<string>(maxLength: 50, nullable: true),
                    UpdatorName = table.Column<string>(maxLength: 50, nullable: true),
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_News", x => x.Id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "News");

            migrationBuilder.AlterColumn<string>(
                name: "ParentId",
                table: "Department",
                maxLength: 50,
                nullable: true,
                oldClrType: typeof(long),
                oldNullable: true);
        }
    }
}
